﻿using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.ExpressApp.DC;
using DevExpress.Persistent.Base;
using DevExpress.Xpo;
using DevExpress.Persistent.Validation;
using DevExpress.ExpressApp;

namespace DomainComponents.XCRM {
    public class AccountValidationRules {
        public const string AccountNameIsRequired = "AccountNameIsRequired";
    }

    [DomainComponent]
    [VisibleInReports]
    [ImageName("BO_Customer")]
    [XafDisplayName("Account")]
    public interface IAccount : ICustomer {
        [RuleRequiredField(AccountValidationRules.AccountNameIsRequired, DefaultContexts.Save)]
        string AccountName { get; set; }

        IContact PrimaryContact { get; set; }

        [VisibleInListView(false)]
        string WebSite { get; set; }

        [VisibleInListView(false)]
        string NumberOfEmployees { get; set; }

        [VisibleInListView(false)]
        string SICCode { get; set; }

        [VisibleInListView(false)]
        decimal AnnualRevenue { get; set; }
        
        [BackReferenceProperty("Account")]
        IList<IContact> Contacts { get; }
    }

    [DomainLogic(typeof(IAccount))]
    public class AccountLogic {
        public static string Get_Name(IAccount account) {
            return account.AccountName;
        }
   }
}
